<!--
 * @description  : 市管-检查详情
 * @descriptionDetail: 市管-检查详情
 * @copyright    : 浙江烟草
 * @author       : sy
 * @create       : 2022-09-09 18:43:02
-->
<template>
  <view :class="checkInfo.status == M_DAY_CHECK_STATUS.FINISH ? '' : 'page'">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar
      :is-white="false"
      :title="navTitle"
      :custom-back="goBack"
      style="z-index: 997"
    >
      <!-- 导航栏右侧下拉按钮 -->
      <view class="nav-right-icon" v-if="checkDealTypes.length > 0">
        <u-icon color="#FFF" name="more-dot-fill" size="38" @click="isOpen = true"></u-icon>
      </view>
    </theme-navbar>
    <!-- #endif -->
		<!-- #ifdef H5-WECHAT || H5-EMP -->
		<fab-button :content="fContent" @fabtrigger="fabtrigger" />
		<!-- #endif -->
    <u-action-sheet :list="addBtnsList" v-model="isOpen" @click="handlerDeal"></u-action-sheet>
    <view class="content">
      <view class="wrap">
        <u-swiper img-mode="scaleToFill" :list="imgList" :effect3d="false" mode="rect"></u-swiper>
      </view>
      <view class="c-title">
        {{ checkInfo.taskSubject == CHECK_TASK_SUBJECT.haveLicense ? checkInfo.companyName : `${checkInfo.companyName}(无证户)` }}
      </view>
      <!-- 检查菜单 margin-top: 30px;-->
      <view style="position: relative;">
        <view class="opt-img">
          <u-row v-if="(!taskInfo.status || taskInfo.status == '') && (!taskInfo.clientSign.status || taskInfo.clientSign.status == '')">
            <u-col span="4" style="text-align: right;" v-if="taskInfo.taskSubject == CHECK_TASK_SUBJECT.haveLicense">
              <u-icon size="108" name="../../static/check/round-nfc.png" v-if="retailer && retailer.nfcNo" @tap="handlerNfc"></u-icon>
              <u-icon size="108" name="../../static/check/round-nfc2.png" v-else></u-icon>
            </u-col>
            <u-col :span="taskInfo.taskSubject == CHECK_TASK_SUBJECT.haveLicense?'4':'7'" style="text-align: center;">
              <u-icon size="108" name="../../static/check/round-scan.png" @tap="handlerScan"></u-icon>
            </u-col>
            <u-col :span="taskInfo.taskSubject == CHECK_TASK_SUBJECT.haveLicense?'4':'5'" style="text-align: left;">
              <u-icon size="108" name="../../static/check/round-checkin.png" @tap="signSheetShow = true"></u-icon>
            </u-col>
          </u-row>
          <u-row v-else>
            <u-col span="12" class="u-p-l-50">
              <u-time-line>
                <u-time-line-item nodeTop="10">
                  <!-- 此处没有自定义左边的内容，会默认显示一个点 -->
                  <template #content>
                    <view>
                      <view class="u-order-title">
                        <span>
                          {{ taskInfo.clientSign.signInTime || pageSignInTime }}
                        </span>
                      </view>
                    </view>
                  </template>
                </u-time-line-item>
                <u-time-line-item>
                  <template #content>
                    <view>
                      <view class="u-order-title">
                        <span>
                          {{ taskInfo.checkTime || checkTime }}
                        </span>
                      </view>
                    </view>
                  </template>
                </u-time-line-item>
              </u-time-line>
            </u-col>
          </u-row>
        </view>
        <view class="">
          <u-gap :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
        </view>
        <u-card title="检查菜单" margin="0rpx" :border="false" border-radius="70" :head-style="headStyle" :body-style="bodyStyle">
          <view slot="body">
            <u-grid :col="3" :border="false">
              <u-grid-item v-for="(item, idx) in checkMenus" :key="idx" @click="handlerCheckMenu(item)">
                <u-badge :count="item.count" :offset="[10, 50]" v-if="item.count && item.count > 0"></u-badge>
                <u-icon :name="item.icon" :size="48"></u-icon>
                <view class="grid-text">
                  {{ item.label }}
                </view>
              </u-grid-item>
            </u-grid>
          </view>
        </u-card>
      </view>
      <!-- 信息查询菜单 -->
      <view>
        <u-card title="信息查询" margin="0rpx" :border="false" border-radius="70" :head-style="headStyle" :body-style="bodyStyle">
          <view slot="body">
            <u-grid :col="3" :border="false">
              <u-grid-item v-for="(item, idx) in infoMenus" :key="idx" @click="handlerCheckInfoMenu(item)">
                <u-icon :name="item.icon" :size="48"></u-icon>
                <view class="grid-text">
                  {{ item.label }}
                </view>
              </u-grid-item>
            </u-grid>
          </view>
        </u-card>
      </view>
    </view>
    <view class="space-content"></view>
    <view class="submit-btns btn-other-cls" v-if="(!taskInfo.status || (taskInfo.status != M_DAY_CHECK_STATUS.FINISH && taskInfo.status != '03')) && taskInfo.clientSign.status == M_DAY_CHECK_STATUS.SIGN">
      <u-button class="u-btn" style="width: 99%;" type="primary" size="medium" @click="handlerSubmit">
        提交
      </u-button>
    </view>
    <!-- 手工签到 -->
    <u-action-sheet :list="signList" v-model="signSheetShow" @click="handlerSign"></u-action-sheet>
    <!-- 检查菜单组件 -->
    <u-popup mode="bottom" height="100%" z-index="998" border-radius="16" v-model="menuOpen">
      <component
        :menuData="menuItem"
        :checkGroup="taskInfo.groupUuid"
        :recordDatas="licenceRecords"
        :checkGuides="menuItemCountMap"
        :actionEvent="actionEvent"
        :isDisabled="taskInfo.status == M_DAY_CHECK_STATUS.FINISH"
        :is="menuItem.com"
        :retailer="retailer"
        :prevCheckInfo="prevCheckInfo"
        ref="refCom"
        @ok="handlerComplete"
        @close="handlerCloseComp"
      ></component>
    </u-popup>
    <!-- 检查结果选择 -->
    <u-popup mode="bottom" height="80%" border-radius="16" v-model="checkResultTypeOpen">
      <multi-select :isDisabled="true" :options="checkResultTypeDict" :title="'检查结果'" :defaultUids="checkedResultType" @select="handlerSelectResultType"></multi-select>
    </u-popup>
  </view>
</template>
<script>
	/**
	 * 检查详情
	 */
	import checkService from '@/service/check/check.service';
	import rlicService from '@/service/certificate/rlic.service';
	import certService from '@/service/certificate/certificate.service';
	import commonService from '@/service/eCigar/common.service';
	import commonCqService from '@/service/common/common.service';
	import caseOfficeService from '@/service/case/office.service';
	import {
		dateUtils
	} from '@/common/util';
	import RetailerCom from './components/retailer-com.vue';
	import MaintainCom from './components/maintain-com.vue';
	import ComplainCom from './components/complain-com.vue';
	import UniversalCom from './components/universal-com.vue';
	import multiSelect from '@/components/multi-select.vue';
	import certificateService from '@/service/certificate/certificate.service.js';
	import {
		CHECK_TASK_SUBJECT
	} from '@/common/common_enum.js';
	import {
		M_CHECK_GROUP,
		M_DAY_CHECK_STATUS,
		M_CHECK_HANDLE_RESULT,
		APPLAP_TYPE
	} from '@/service/check/mapping/enum.js';
	import {
		CASE_TYPE,
		CASE_SOURCE
	} from '@/service/case/mapping/index.js';
	import {
		isDD,
		isWorkWechat,
    isEmpApp
	} from '@/common/util';
	import {
		SET_MAP_LAT_LON
	} from '@/config/setting.config.js';
	import fabButton from '@/components/uni-fab.vue';


	export default {
		components: {
			multiSelect,
			MaintainCom,
			ComplainCom,
			RetailerCom,
			UniversalCom,
			fabButton
		},
		data() {
			return {
				M_DAY_CHECK_STATUS,
				M_CHECK_GROUP,
				M_CHECK_HANDLE_RESULT,
				APPLAP_TYPE,
				state: false,
				isOpen: false,
				user: this.$storage.get(this.$rp.common.USER),
				isSubmit: false, // 是否提交了检查(用于判断返回时是否刷新列表)
				signSheetShow: false, // 手动签到
				menuOpen: false,
				beginTime: '',
				retailerWorkInfo: {},
				checkInfo: {},
				taskInfo: {
					clientSign: {
						status: '',
						statusName: '',
						signInTime: ''
					},
				}, // 检查任务详情
				menuItemCountMap: {}, // 检查作业指导书信息
				actionEvent: {}, // 事件对象
				retailer: {},
				imgList: [], // 展示的零售户照片
				checkMenus: [],
				checkMenusAll: [
					// 不同类型具体项有所不同
					{
						label: '涉案问题',
						type: 'in',
						com: UniversalCom,
						auth: ['normal', 'random', 'nolicense'],
						recordType: '91301',
						icon: '../../static/check/icon_in.png',
					},
					{
						label: '证照问题',
						type: 'out',
						com: UniversalCom,
						auth: ['normal', 'random'],
						recordType: '91302',
						icon: '../../static/check/icon_out.png'
					},
					{
						label: '规范问题',
						type: 'business',
						com: UniversalCom,
						auth: ['normal', 'random'],
						recordType: '91303',
						icon: '../../static/check/icon_business.png',
					},
					{
						label: '执法风险',
						type: 'licence',
						com: UniversalCom,
						auth: ['normal', 'random', 'nolicense'],
						recordType: '91304',
						icon: '../../static/check/icon_licence.png',
					},
					{
						label: '关联登记',
						type: 'retailer',
						com: RetailerCom,
						auth: ['normal', 'random', 'nolicense'],
						recordType: '91305',
						icon: '../../static/check/icon_illegal.png',
						count: 0,
					},
					{
						label: '信息维护',
						type: 'maintain',
						com: MaintainCom,
						auth: ['normal', 'random', 'nolicense'],
						recordType: '91306',
						icon: '../../static/check/icon_maintain.png',
					},
					{
						label: '备忘录',
						type: 'memo',
						com: UniversalCom,
						auth: ['normal', 'random'],
						recordType: '91307',
						icon: '../../static/check/icon_txt.png'
					},
					{
						label: '普法宣传',
						type: 'statutePublicize',
						com: UniversalCom,
						auth: ['normal', 'random'],
						recordType: '91311',
						icon: '../../static/check/statute_publicize_icon.png'
					},
				],
				infoMenus: [],
				infoMenusAll: [{
					label: '档案信息',
					auth: ['normal', 'random', 'nolicense'],
					type: 'archive',
					icon: '../../static/check/icon_archive.png'
				}],
				headStyle: {
					fontWeight: 600,
				},
				bodyStyle: {
					paddingTop: 0,
				},
				longitude: 0, // 经度
				latitude: 0, // 纬度
				signList: [],
				menuItem: {}, // 点击的菜单
				memo: '', // 备忘录
				licenceRecords: [],
				checkHandleResultDict: [], // 检查结果字典
				checkResultTypeDict: this.$store.state.dicts['M_CHECK_HANDLE_RESULT'], // 检查处理方式字典
				checkResultTypeOpen: false, // 检查结果弹窗
				checkedResultType: [], // 已选中的处理方式
				checkDealTypes: [], // 检查处理结果
				localStoreTaskKey: '', // 本地缓存的检查结果数据key值
				videoId: '', // 视频Id
				userCode: '',
				startTime: '', // 开始录像时间
				endTime: '', // 录像结束时间
				CHECK_TASK_SUBJECT,
				singleCheckRecords: [], // 单层结构的检查项-提交时用
				addBtnsList: [],
				pageSignInTime: '',
				checkTime: '未完成',
				prevCheckInfo: [],
				prevTypeList: [],
				applyCode: '',
				isReportHotline: false,
				fContent: [{
					iconPath: require('@/static/omore.png'),
					selectedIconPath: require('@/static/omore.png'),
					text: '更多',
					active: false,
				}],
			};
		},
		mounted() {
			this.userCode = this.$storage.get(this.$rp.common.USER).user.personCode;
			// console.log("缓存的任务数据", uni.getStorageSync("taskInfoDetail"));
			this.checkInfo = this.getRouteParam();
			console.log(this.checkInfo);
			this.localStoreTaskKey = 'taskInfoDetail-' + this.checkInfo.checkUuid;
			let storageTaskInfo = uni.getStorageSync(this.localStoreTaskKey);
			console.log(storageTaskInfo);
			// 如果已签到且有本地缓存任务的情况下，直接使用本地缓存，否则查询数据库
			// status=''或者不返回字段是未开始，status='2'已签到，status='02'已完成 03 已终止
			if (this.$u.test.isEmpty(this.checkInfo.status)) {
				this.getCheckCountInfo();
			}
			if (this.checkInfo.status != M_DAY_CHECK_STATUS.FINISH && this.checkInfo.status != '03' && storageTaskInfo) {
				this.taskInfo = storageTaskInfo;
				this.initCheckMenu();
				// 查询照片
				this.queryImgs();
			} else {
				this.queryTaskInfo();
				this.queryCheckResultDetail(() => this.setRightBtnsCheck());
			}
			this.queryCheckSignReason();
			this.getLocation();
			this.queryRetailer();
			// 字典数据
			this.getDicts();
			// 过滤 “停业整顿”
			this.checkResultTypeDict = this.checkResultTypeDict.filter((item) => {
				return item.bcbCode != M_CHECK_HANDLE_RESULT.STOP_RECTIFY; // '10210052'
			});
		},
		onShow() {
			this.checkInfo.status == M_DAY_CHECK_STATUS.FINISH && this.queryCheckResultDetail(() => this.setRightBtnsCheck());
		},
		methods: {
			// 初始化菜单
			initCheckMenu() {
				switch (this.taskInfo.groupUuid) {
					// 常规检查任务
					case M_CHECK_GROUP.NORMAL: // 32001
						this.dealMenu('normal');
						break;
						// 无证户
					case M_CHECK_GROUP.NOLICENSE: // 32012
						this.dealMenu('nolicense');
						break;
						// 协同处理
					case '32009':
						this.dealMenu('deal');
						break;
						// 随机抽查
					case M_CHECK_GROUP.RANDOM: // 32014
						this.dealMenu('random');
						break;
					default:
						break;
				}
			},
			getUndertaker() {
				let undertaker = [];
				let undertakerUuid = [];
				if (this.taskInfo.executorVOS && this.taskInfo.executorVOS.length > 0) {
					this.taskInfo.executorVOS.forEach((item) => {
						undertakerUuid.push(item.personUuid);
						undertaker.push(item.personName);
					});
				}
				this.taskInfo.undertakerUuid = undertakerUuid.join(',');
				this.taskInfo.undertaker = undertaker.join(',');
			},
			// 处理检查、查询菜单
			dealMenu(type) {
				this.checkMenusAll.forEach((m) => m.auth.includes(type) && this.checkMenus.push(m));
				this.infoMenusAll.forEach((m) => m.auth.includes(type) && this.infoMenus.push(m));
				if (type == 'nolicense') {
					this.checkMenus.forEach((m) => m.type == 'in' && (m.comData = this.taskInfo.checkRecords[0].workItems)); //
					this.checkMenus.forEach((m) => m.type == 'retailer' && (m.comData = this.taskInfo.checkRecords[2].workItems));
					this.checkMenus.forEach((m) => m.type == 'licence' && (m.comData = this.taskInfo.checkRecords[1].workItems));
					// this.checkMenus.forEach(m => m.type == 'retailer' && (m.comData = this.taskInfo.checkRecords[3].workItems));
					this.checkMenus.forEach((m) => m.type == 'maintain' && (m.comData = this.taskInfo.checkRecords[3].workItems));
				} else {
					this.checkMenus.forEach((m) => m.type == 'in' && (m.comData = this.taskInfo.checkRecords[0].workItems)); //
					this.checkMenus.forEach((m) => m.type == 'out' && (m.comData = this.taskInfo.checkRecords[1].workItems));
					this.checkMenus.forEach((m) => m.type == 'business' && (m.comData = this.taskInfo.checkRecords[2].workItems));
					this.checkMenus.forEach((m) => m.type == 'licence' && (m.comData = this.taskInfo.checkRecords[3].workItems));
					this.checkMenus.forEach((m) => m.type == 'maintain' && (m.comData = this.taskInfo.checkRecords[5].workItems));
					this.checkMenus.forEach((m) => m.type == 'memo' && (m.comData = this.taskInfo.checkRecords[6].workItems));
					this.checkMenus.forEach((m) => m.type == 'statutePublicize' && (m.comData = this.taskInfo.checkRecords[7].workItems));
				}
				this.getTypePrevCount();
			},
			// 查询展示的零售户照片
			queryImgs() {
				let jgRoot = `${commonService.baseUrl}/commonfile/filestore/downloadOnlineFile.do?tk=${uni.getStorageSync('tk')}&fileUrl=`;
				let zmRoot = `${commonService.baseUrl}/commonfile/filestore/downloadFile.do?tk=${uni.getStorageSync('tk')}&fileId=`;
				Promise.all([
					checkService.jgPlatformPicture(this.taskInfo.retailerUuid),
					checkService.getPictureByRetailerUuid({
						retailerUuid: this.taskInfo.retailerUuid,
						taskSubject: this.taskInfo.taskSubject
					}),
				]).then((drs) => {
					// 经管照片
					if (drs[0].success) {
						let jgPic = drs[0].bean || {};
						jgPic.store_image_fid && this.imgList.push({
							image: jgRoot + encodeURIComponent(jgPic.jg_store_image)
						});
						jgPic.counter_image_fid && this.imgList.push({
							image: jgRoot + encodeURIComponent(jgPic.jg_counter_image)
						});
						jgPic.cust_image_fid && this.imgList.push({
							image: jgRoot + encodeURIComponent(jgPic.jg_cust_image)
						});
						jgPic.lice_image_fid && this.imgList.push({
							image: jgRoot + encodeURIComponent(jgPic.jg_lice_image)
						});
						jgPic.back_counter_image_fid && this.imgList.push({
							image: jgRoot + encodeURIComponent(jgPic.jg_back_counter_image)
						});
					}
					// 零售户照片
					if (drs[1].success) {
						let reta = drs[1].bean || {};
						reta.storeImageUuid && this.imgList.push({
							image: zmRoot + reta.storeImageUuid
						});
						reta.counterImageUuid && this.imgList.push({
							image: zmRoot + reta.counterImageUuid
						});
						reta.custImageUuid && this.imgList.push({
							image: zmRoot + reta.custImageUuid
						});
						reta.liceImageUuid && this.imgList.push({
							image: zmRoot + reta.liceImageUuid
						});
						reta.backCounterImageUuid && this.imgList.push({
							image: zmRoot + reta.backCounterImageUuid
						});
					}
					// 如果没有照片，显示一个无照片
					console.log(this.imgList);
					if (this.imgList.length == 0) {
						this.imgList.push({
							image: require('../../static/check/nophoto.png')
						});
					}
				});
			},
			updateBackState(param) {
				// 地图定位
				if (param.pos) {
					this.actionEvent = {
						event: 'pos',
						value: param.pos,
					};
					return;
				}
				// 选中的关联经营户
				let addRelRetailers = param['temporaryTask'];
				if (addRelRetailers) {
					// 转换选中的经营户数据
					let relRes = [];
					let supplyList = [];
					addRelRetailers.forEach((r) => {
						// 关联登记
						if (this.menuItem.type == 'retailer') {
							relRes.push({
								businessAddr: r.businessAddr,
								companyName: r.companyName,
								relLicNo: r.licNo,
								managerName: r.managerName,
								relRetailerUuid: r.retailerUuid,
								relSubjectType: r.taskSubject,
								ownerRetailerUuid: this.taskInfo.retailerUuid,
								ownSubjectType: this.taskInfo.taskSubject,
								relation: '',
								relationName: '',
							});
						}
						if (this.menuItem.type == 'maintain') {
							// 供货来源
							supplyList.push({
								businessAddr: r.businessAddr,
								companyName: r.companyName,
								licNo: r.licNo,
								managerName: r.managerName,
								retailTel: r.retailTel,
								retailerUuid: r.retailerUuid,
								subjectType: r.taskSubject,
							});
						}
					});
					let mItem = this.$u.deepClone(this.menuItem);
					mItem.relRetailers = [...relRes];
					mItem.supplySources = [...supplyList];
					this.menuItem = mItem;
				}
				if (param.refresh) {
					let mItem = this.$u.deepClone(this.menuItem);
					mItem.refeshGis = true;
					this.menuItem = mItem;
				}
			},
			// 手工签到原因
			queryCheckSignReason() {
				checkService.bscCodesMap('M_CHECK_HANDSIGN_REASON').then((dr) => {
					if (dr.success) {
						dr.bean['M_CHECK_HANDSIGN_REASON'].forEach((c) => this.signList.push({
							type: c.bcbCode,
							text: c.bcbName,
							color: '#007aff'
						}));
					}
				});
			},
			// 定位
			getLocation() {
				if (isDD() || isWorkWechat() || isEmpApp()) {
					this.$deviceApi.geolocation().then((geo) => {
						this.longitude = geo.longitude;
						this.latitude = geo.latitude;
					});
				} else {
					this.longitude = SET_MAP_LAT_LON[0];
					this.latitude = SET_MAP_LAT_LON[1];
				}
			},
			getTypePrevCount() {
				if (this.checkMenus.length == 0 || this.prevTypeList.length == 0) return;
				this.checkMenus.forEach((ip) => {
					ip.count = 0;
					for (let i = 0; i < this.prevTypeList.length; i++) {
						if (this.prevTypeList[i].itemUuid == ip.recordType) {
							try {
								ip.count = Number(this.prevTypeList[i].itemCount);
							} catch (e) {
								console.log(e);
							}
							break;
						}
					}
				});
			},
			getCheckCountInfo() {
				checkService
					.getCheckCountInfo(this.checkInfo.retailerUuid)
					.then((res) => {
						if (res.success) {
							let tmp = res.bean || {};
							this.prevCheckInfo = tmp.checkItemList || [];
							this.prevTypeList = tmp.typeList || [];
							this.getTypePrevCount();
						} else {
							console.log(res.msg);
						}
					})
					.catch((e) => {
						console.log(e);
					});
			},
			// 查询检查任务
			queryTaskInfo() {
				this.$u.loading('数据加载中...');
				let checkRecord = '';
				checkRecord = checkService.getCheckRecords;
				checkRecord(this.checkInfo.checkUuid, '1')
					.then((dr) => {
						this.$u.hideLoading();
						if (dr.success) {
							this.taskInfo = dr.bean;
							this.taskInfo['clientSign'] = this.taskInfo['clientSign'] ? this.taskInfo['clientSign'] : {};
							!this.taskInfo.longitude && (this.taskInfo.longitude = this.checkInfo.longitude);
							!this.taskInfo.latitude && (this.taskInfo.latitude = this.checkInfo.latitude);
							this.initCheckMenu();
							// 查询照片
							this.queryImgs();
							this.getUndertaker();
						} else {
							this.$u.toast(dr.msg);
						}
					})
					.catch((err) => {
						this.$u.hideLoading();
						this.$u.toast(err);
					});
			},
			// 查询检查结果详情(仅在提交后查询)
			queryCheckResultDetail(cb) {
				checkService.findCheckDealResultList(this.checkInfo.checkUuid).then((dr) => {
					if (dr.success) {
						// 过滤停业整顿
						if (dr.data.length > 0) {
							this.applyCode = dr.data[0].applyCode;
						}
						if (this.$u.test.isEmpty(this.applyCode)) {
							this.isReportHotline = false;
						} else {
							this.isReportHotline = true;
						}
						this.checkDealTypes = dr.data.filter((item) => {
							return item.code != M_CHECK_HANDLE_RESULT.STOP_RECTIFY; // 10210052
						});
						this.getBtnList();
						cb && cb();
					} else {
						this.$u.toast(dr.msg);
					}
				});
			},
			getBtnList() {
				this.addBtnsList = [];
				if (this.checkDealTypes.length > 0) {
					this.checkDealTypes.forEach((item, index) => {
						this.addBtnsList.push({
							text: item.name,
							index: index
						});
					});
				}
			},
			// 查询零售户信息
			queryRetailer() {
				checkService.retailerDetail({
					retailerUuid: this.checkInfo.retailerUuid
				}).then((dr) => {
					if (dr.success) {
						this.retailer = dr.bean;
					}
				});
			},
			// NFC
			handlerNfc() {
				if (!this.retailer.nfcNo) {
					this.$u.toast('当前零售户未制作NFC');
					return;
				}
				this.$deviceApi
					.nfcReader()
					.then((code) => {
						if (!code) {
							this.$u.toast('无法识别');
							return;
						}
						/*
          现有NFC数据有两种数据格式：
          1：04A0931AAA5280
          2：{content : "1234667890",tagId : "04:48:7c:1a:aa:52:81"}
        */
						let nfcNo = '';
						if (code['tagId']) {
							nfcNo = code['tagId'].replace(/:/g, '');
						} else {
							nfcNo = code.replace(/:/g, '');
						}
						if (this.retailer.nfcNo.toUpperCase() == nfcNo.toUpperCase()) {
							// 签到
							this.checkSign('02', '');
						} else {
							this.$u.toast(`读取到的NFC信息与当前NFC卡不一致，读取信息【${nfcNo}】，NFC卡信息【${this.retailer.nfcNo}】`);
						}
					})
					.catch((ep) => {
						this.$u.toast('识别失败:' + ep);
					});
			},
			// 扫码
			handlerScan() {
				this.$deviceApi.scan().then((res) => {
					let licNo = this.getLicenseCode(res); // res.replace(/ +/g,"").replace(/[\r\n]/g,"");
					if (this.$u.test.isEmpty(licNo)) {
						this.$u.toast('二维码无法识别：' + res);
						return;
					}
					console.log("licNo::", licNo)
					console.log("retailer.licNo::", this.retailer.licNo)
					// 识别成功
					if (licNo != this.retailer.licNo) {
						this.$u.toast('您扫描的信息与当前零售户不一致');
						return;
					}
					this.checkSign('01', '');
				});
			},
			/**
			 * 从扫描或NFC获取的零售户信息中提取许可证号
			 * 不同的地区二维码信息不同，如果无法识别，需要修改本方法，添加相关特列
			 * 通用逻辑：查找到“许可证”后的第一个数字串即认为是许可证号
			 */
			getLicenseCode(scanRetailerInfo) {
				let index = scanRetailerInfo.indexOf('许可证号:');
				let qCodeStr = '';
				let lic = '';
				if (index != -1) qCodeStr = scanRetailerInfo.substring(index, scanRetailerInfo.indexOf(','));
				!qCodeStr && (qCodeStr = scanRetailerInfo.substring(0, 12));
				if (!qCodeStr) {
					lic = '';
				}
				let matches = qCodeStr.match(/[0-9]+/);
				if (matches.length > 0) lic = matches[0]; // 识别成功
				if (!this.$u.test.isEmpty(lic)) {
					try {
						lic = this.$u.trim(lic);
					} catch (e) {
						console.log(e);
					}
				}
				return lic;
			},
			// 手工签到
			handlerSign(i) {
				this.checkSign('03', this.signList[i].type);
			},
			// 签到 reasonCode手工签到编码
			checkSign(signType, reasonCode) {
				let isHaveLngLat = false;
				if (this.longitude == 0 && this.latitude == 0) {
					this.$modal.alert('获取当前位置信息失败,请稍后重新签到？', () => {
						this.getLocation();
					});
					return;
				}
				this.$u.loading('正在计算当前位置...');
				this.taskInfo.signType = signType; // 签到方式
				this.taskInfo.signCode = reasonCode; // 手工签到原因
				this.taskInfo.signLongitude = this.longitude;
				this.taskInfo.signLatitude = this.latitude;
				this.taskInfo.isDeviate = 0;
				// 计算签到距离
				if (this.taskInfo.longitude && this.taskInfo.latitude) {
					isHaveLngLat = true;
					let p1 = new AMap.LngLat(this.taskInfo.signLongitude, this.taskInfo.signLatitude);
					let p2 = new AMap.LngLat(this.taskInfo.longitude, this.taskInfo.latitude);
					this.taskInfo.deviateDistance = Math.round(p1.distance(p2));
					console.log('两点相距=' + this.taskInfo.deviateDistance);
					if (this.taskInfo.deviateDistance > 1000) {
						this.taskInfo.isDeviate = 1;
					}
				} else {
					// 没有坐标默认偏离
					this.taskInfo.isDeviate = 1;
				}
				this.$u.hideLoading();
				// 如果当前位置与零售位置相差1000米则提示
				if (this.taskInfo.isDeviate == 1 && isHaveLngLat) {
					this.$modal.confirm(
						'您当前位置距离零售户' + this.taskInfo.deviateDistance + '米，是否继续签到？',
						'提示',
						() => {
							this.doSignIn();
						},
						() => {
							this.getLocation();
						},
						'确定',
						'稍后重试'
					);
				} else {
					this.doSignIn();
				}
			},
			/**
			 * 检查关联信息
			 */
			eviClick() {
				// status 为空或者不返回
				if (!this.taskInfo.status || this.taskInfo.status == '') return;
				this.setRouteParam({
					readOnly: !(this.taskInfo.clientSign.status != M_DAY_CHECK_STATUS.SIGN),
					checkUuid: this.taskInfo.checkUuid,
				});
				this.$u.route('/pages/check/photoEvdInfo');
			},
			// 提交签到
			doSignIn() {
				this.$u.loading('正在签到...');
				this.taskInfo.signInTime = dateUtils.dateFormat('yyyy-MM-dd HH:mm:ss', new Date());
				let signTask = this.$u.deepClone(this.taskInfo);
				delete signTask.checkRecords;
				delete signTask.problemCigInfos;
				delete signTask.suspectedPeoples;
				delete signTask.relRetailers;
				delete signTask.reportComplaints;
				delete signTask.personInfos;
				delete signTask.storageInfos;
				delete signTask.vehicleInfoMts;
				delete signTask.supplySources;
				delete signTask.checkPicMts;
				delete signTask.checkDealResultVO;
				checkService
					.saveClientSign(signTask)
					.then((dr) => {
						this.$u.hideLoading();
						if (dr.success) {
							this.$u.toast('签到成功！');
							this.taskInfo.clientSign.status = M_DAY_CHECK_STATUS.SIGN;
							this.taskInfo.clientSign.statusName = '已签到';
							this.pageSignInTime = dateUtils.dateFormat('yyyy-MM-dd HH:mm:ss', new Date());
							this.taskInfo.clientSign.signInTime = dateUtils.dateFormat('yyyy-MM-dd HH:mm:ss', new Date());
							this.$forceUpdate();
						} else {
							this.$u.toast('签到失败: ' + dr.msg);
						}
					})
					.catch((err) => {
						this.$u.hideLoading();
						this.$u.toast(err);
					});
			},
			// 点击检查菜单模块
			handlerCheckMenu(mItem) {
				if ((!this.taskInfo.status || this.taskInfo.status == '') && (!this.taskInfo.clientSign.status || this.taskInfo.clientSign.status == '')) {
					this.$u.toast('请先签到');
					return;
				}
				this.menuItem = mItem;
				if (this.menuItem.recordType) {
					let list = this.taskInfo.checkRecords.filter((c) => c.code == this.menuItem.recordType)[0].workItems;
					this.menuItem.records = list ? list : [];
				}
				this.menuItem.checkInfo = this.checkInfo;
				this.licenceRecords = mItem.comData;
				switch (mItem.type) {
					case 'in': // 流入问题 (涉案问题)
						// 登记的卷烟信息
						this.menuItem.problemCigInfos = this.taskInfo.problemCigInfos;
						// 线索登记的人员信息
						this.menuItem.suspectedPeoples = this.taskInfo.suspectedPeoples;
						// 涉案窝点信息
						this.menuItem.caseDensInfos = this.taskInfo.caseDensInfos;
						// 涉案车辆信息
						this.menuItem.caseCarInfos = this.taskInfo.caseCarInfos;
						break;
					case 'out': // 流出问题（证照问题）
					case 'business': // 规范经营问题（规范问题）
					case 'licence': // 许可证问题（执行风险）
						break;
					case 'retailer': // 关联经营户
						this.menuItem.relRetailers = this.taskInfo.relRetailers;
						this.menuItem.delRelUuids = this.taskInfo.delRelUuids || [];
						break;
					case 'maintain': // 信息维护
						this.menuItem.storageInfos = this.taskInfo.storageInfos;
						this.menuItem.vehicleInfoMts = this.taskInfo.vehicleInfoMts;
						this.menuItem.personInfos = this.taskInfo.personInfos;
						this.menuItem.supplySources = this.taskInfo.supplySources;
						this.menuItem.delPersonUuids = this.taskInfo.delPersonUuids || [];
						break;
					case 'complain': // 投诉举报与建议
						this.menuItem.complains = this.taskInfo.complains;
						break;
					case 'memo': // 备忘录
					case 'statutePublicize': // 普法宣传
						break;
				}
				this.menuOpen = true;
			},
			// 点击信息查询模块菜单
			handlerCheckInfoMenu(mItem) {
				switch (mItem.type) {
					case 'archive': // 档案信息
						// TODO 无证户详情组件传参待定
						if (this.taskInfo.taskSubject == this.CHECK_TASK_SUBJECT.noHaveLic) this.setRouteParam({
							retailerUuid: this.taskInfo.retailerUuid
						});
						this.$u.route(
							this.taskInfo.taskSubject == this.CHECK_TASK_SUBJECT.haveLicense ?
							'/pages/retailer/retailerInfo/retailerInfo?retailerUuid=' + this.taskInfo.retailerUuid :
							'/pages/query/nolicence/detailUnlicense'
						);
						break;
					case 'order': // 订单信息
						this.$u.route('/pages/check/checkOrderList?licNo=' + this.taskInfo.licNo);
						break;
					case 'violation': // 违规案件
						this.$u.route('/pages/check/checkCaseHistoryList?licNo=' + this.taskInfo.licNo);
						break;
					case 'check': // 检查情况
						this.$u.route('/pages/check/checkHistoryList?retailerUuid=' + this.taskInfo.retailerUuid + '&isHaveLicense=' + this.taskInfo.isHaveLicense);
						break;
				}
			},
			// 关闭
			handlerCloseComp() {
				this.menuOpen = false;
			},
			// 递归下数据
			treeToLevelList(arr) {
				let att = [];
				Object.keys(arr).forEach((d) => {
					att.push(arr[d]);
					if (arr[d].workItems) {
						arr[d].workItems.forEach((r) => {
							att.push(r);
						});
					}
				});
				return att;
			},
			// 递归赋值动态组件中得值
			recursionCheckRecords(recordDatas, arr) {
				Object.keys(recordDatas).forEach((d) => {
					arr.forEach((item) => {
						if (item.itemUuid == recordDatas[d].itemUuid) {
							// console.log(item.itemUuid + '====' + item.itemName);
							item.checkData = recordDatas[d].checkData;
							// 处理方式
							if (recordDatas[d].checkHandleResult) {
								item.checkHandleResult = recordDatas[d].checkHandleResult;
								item.checkHandleResultLabel = recordDatas[d].checkHandleResultLabel;
							}
							if (item.checkData != undefined) {
								item.isUnusual = item.unusualValue == item.checkData ? 1 : 0;
							}
							if (item.workItems && item.workItems.length > 0) {
								this.recursionCheckRecords(recordDatas, item.workItems);
							}
							return;
						}
					});
				});
			},
			// 菜单组件点击确定，处理选择的数据并进行本地缓存
			handlerComplete(comData) {
				let recordDatas = comData['records'] || comData;
				recordDatas = this.treeToLevelList(recordDatas);
				console.log('recordDatas', recordDatas);
				// console.log(comData.comType);
				// 动态组件确认返回
				if (comData['records']) {
					let newList = [];
					if (this.singleCheckRecords.length > 0) {
						// 判断this.singleCheckRecords中没有的检查项
						newList = recordDatas.filter((d) => !this.singleCheckRecords.some((val) => val.itemUuid == d.itemUuid));
						// console.log(newList);
						this.singleCheckRecords.forEach((item) => {
							Object.keys(recordDatas).forEach((d) => {
								if (item.itemUuid == recordDatas[d].itemUuid) {
									item.checkData = recordDatas[d].checkData;
									// 处理方式
									if (recordDatas[d].checkHandleResult) {
										item.checkHandleResult = recordDatas[d].checkHandleResult;
										item.checkHandleResultLabel = recordDatas[d].checkHandleResultLabel;
									}
									if (item.checkData != undefined) {
										item.isUnusual = item.unusualValue == item.checkData ? 1 : 0;
									}
									return;
								}
							});
						});
						if (newList.length > 0) {
							this.singleCheckRecords = this.singleCheckRecords.concat(newList);
						}
					} else {
						this.singleCheckRecords = [...recordDatas];
					}
					this.taskInfo.singleCheckRecords = this.singleCheckRecords;
					console.log(this.singleCheckRecords);
				}
				if (comData.comType == 'in') {
					this.recursionCheckRecords(recordDatas, this.taskInfo.checkRecords[0].workItems);
					// 线索登记的人员信息
					this.taskInfo.suspectedPeoples = comData.suspectedPeoples;
					// 登记的卷烟信息
					this.taskInfo.problemCigInfos = comData.problemCigInfos;
					// 涉案窝点信息
					this.taskInfo.caseDensInfos = comData.caseDensInfos;
					// 涉案车辆信息
					this.taskInfo.caseCarInfos = comData.caseCarInfos;
				} else if (comData.comType == 'out') {
					this.recursionCheckRecords(recordDatas, this.taskInfo.checkRecords[1].workItems);
				} else if (comData.comType == 'business') {
					this.recursionCheckRecords(recordDatas, this.taskInfo.checkRecords[2].workItems);
				} else if (comData.comType == 'licence') {
					let list = this.taskInfo.groupUuid == M_CHECK_GROUP.NOLICENSE ? this.taskInfo.checkRecords[1].workItems : this.taskInfo.checkRecords[3].workItems;
					this.recursionCheckRecords(recordDatas, list);
				} else if (comData.comType == 'retailer') {
					// 关联登记
					this.taskInfo.relRetailers = comData.relaCustomers;
					this.taskInfo.delRelUuids = comData.delRelUuids;
				} else if (comData.comType == 'maintain') {
					let list = this.taskInfo.groupUuid == M_CHECK_GROUP.NOLICENSE ? this.taskInfo.checkRecords[3].workItems : this.taskInfo.checkRecords[5].workItems;
					this.recursionCheckRecords(recordDatas, list);
					// 仓储信息
					this.taskInfo.storageInfos = comData.storageInfos;
					// 车辆信息
					this.taskInfo.vehicleInfoMts = comData.vehicleInfoMts;
					// 从业人员
					this.taskInfo.personInfos = comData.personInfos;
					this.taskInfo.delPersonUuids = comData.delPersonUuids || [];
					// 供货来源
					this.taskInfo.supplySources = comData.supplySources;
				} else if (comData.comType == 'memo') {
					this.recursionCheckRecords(recordDatas, this.taskInfo.checkRecords[6].workItems);
				} else if (comData.comType == 'statutePublicize') {
					this.recursionCheckRecords(recordDatas, this.taskInfo.checkRecords[7].workItems);
				}
				console.log('缓存数据', this.taskInfo);
				// 本地缓存数据
				uni.setStorageSync(this.localStoreTaskKey, this.taskInfo);

				this.menuOpen = false;
			},
			getLabelRk(type) {
				for (let i = 0; i < this.checkMenusAll.length; i++) {
					if (this.checkMenusAll[i].type == type) {
						return this.checkMenusAll[i].label;
					}
				}
				return '';
			},
			// 获取字典
			getDicts() {
				this.checkHandleResultDict = this.$store.state.dicts['M_CHECK_HANDLE_RESULT'];
			},
			// 处理检查结果
			handlerDeal(type) {
				let hResultDict = this.checkDealTypes[type];
				// console.log("点击了" + type);
				// console.log(hResultDict);
				if (this.taskInfo.status != M_DAY_CHECK_STATUS.FINISH) {
					this.$u.toast('请先提交检查');
					return false;
				}
				this.isOpen = false;
				switch (hResultDict.code) {
					case M_CHECK_HANDLE_RESULT.NO_PROBLEM: // 未发现问题 "10210011"
						this.$u.toast('无需创建文书');
						break;
					case M_CHECK_HANDLE_RESULT.MOUTH_EDUCATION: // 口头宣传教育 "10210031"
						this.$u.toast('无需创建文书');
						break;
					case M_CHECK_HANDLE_RESULT.CONTINUE_NOTICE: // 延续通知 "10210012"
						this.setRouteParam({
							bizUuid: this.taskInfo.checkUuid,
							docCode: 'docContinueNotice',
							retailerUuid: this.taskInfo.retailerUuid,
							dayUuid: this.taskInfo.dayUuid,
						});
						this.$u.route('/pages/certificate/official/licExtendNotice');
						break;
					case M_CHECK_HANDLE_RESULT.ORDER_CHANGE: // 责令变更 "10210051"
						this.$u.loading('查询中...');
						certService
							.getDocInsUuidByLicType(this.taskInfo.checkUuid, APPLAP_TYPE.ORDER_CHANGE)
							.then((dr) => {
								this.$u.hideLoading();
								if (dr.success) {
									if (dr.bean) {
										certificateService.getDocIns(dr.bean).then((res) => {
											if (res.success) {
												this.setRouteParam({
													retailerUuid: this.taskInfo.retailerUuid,
													applyType: APPLAP_TYPE.ORDER_CHANGE,
													docInsUuid: dr.bean || '',
													checkUuid: this.taskInfo.checkUuid,
													licNo: this.checkInfo.licNo,
												});
												this.$u.route('/pages/certificate/official/athApproval');
											}
										});
									} else {
										this.setRouteParam({
											retailerUuid: this.taskInfo.retailerUuid,
											applyType: APPLAP_TYPE.ORDER_CHANGE,
											docInsUuid: dr.bean || '',
											checkUuid: this.taskInfo.checkUuid,
											licNo: this.checkInfo.licNo,
										});
										this.$u.route('/pages/certificate/official/athApproval');
									}
								} else {
									this.$u.toast(dr.msg);
								}
							})
							.catch((e) => {
								this.$u.hideLoading();
							});
						break;
					case M_CHECK_HANDLE_RESULT.STOP_RECTIFY: // 停业整顿 "10210052"
						this.$u.loading('查询中...');
						certService
							.getDocInsUuidByLicType(this.taskInfo.checkUuid, APPLAP_TYPE.STOP_RECTIFY)
							.then((dr) => {
								this.$u.hideLoading();
								if (dr.success) {
									this.setRouteParam({
										retailerUuid: this.taskInfo.retailerUuid,
										applyType: APPLAP_TYPE.STOP_RECTIFY,
										docInsUuid: dr.bean || '',
										checkUuid: this.taskInfo.checkUuid,
										licNo: this.checkInfo.licNo,
									});
									this.$u.route('/pages/certificate/official/athApproval');
								} else {
									this.$u.toast(dr.msg);
								}
							})
							.catch((e) => {
								this.$u.hideLoading();
							});
						break;
					case M_CHECK_HANDLE_RESULT.ORDER_CORRECT: // 责令纠正 "10210053"
						this.setRouteParam({
							bizUuid: this.taskInfo.checkUuid,
							docCode: 'docCorrect',
							retailerUuid: this.taskInfo.retailerUuid,
							dayUuid: this.taskInfo.dayUuid,
						});
						this.$u.route('/pages/certificate/official/orderCorrectNotice');
						break;
					case M_CHECK_HANDLE_RESULT.SIMPLE_CASE: // TODO 简易案件 "10210021"
						if (hResultDict.caseUuid) {
							this.setRouteParam({
								caseUuid: hResultDict.caseUuid,
								from: 'check',
							});
							this.$u.route('/pages/case/offline/caseInfo');
						} else {
							this.setRouteParam({
								initQueryData: {},
							});
							this.$u.route({
								url: '/pages/case/components/caseFilingLink',
								type: 'to',
								params: {
									caseType: CASE_TYPE.SIMPLE,
									checkActionCode: hResultDict.checkActionCode,
									// 添加检查事项名称和code 解决立案页面无法显示问题 fsx 2023-12-8 开始
									superviseItemName: hResultDict.superviseItemName,
									jgsxDealUuid: hResultDict.jgsxDealUuid,
									caseSource: CASE_SOURCE.marketCheck, // 市场查获
									// 添加检查事项名称和code 解决立案页面无法显示问题 fsx 2023-12-8 结束
									checkUuid: this.taskInfo.checkUuid,
									from: 'check', // 表示从市管过去的
									undertaker: this.taskInfo.undertaker,
									undertakerUuid: this.taskInfo.undertakerUuid,
									applyCode: this.applyCode,
									isReportHotline: this.isReportHotline,
									isSpecialAction: hResultDict.isSpecialAction == '1',
									actionUuid: hResultDict.actionUuid || '',
									actionName: hResultDict.actionName || '',
								},
							});
						}
						break;
					case M_CHECK_HANDLE_RESULT.GENERAL_CASE: // 一般案件 "10210022"
						if (hResultDict.caseUuid) {
							this.setRouteParam({
								caseUuid: hResultDict.caseUuid,
								from: 'check',
							});
							this.$u.route('/pages/case/offline/caseInfo');
						} else {
							this.setRouteParam({
								initQueryData: {},
							});
							this.$u.route({
								url: '/pages/case/components/caseFilingLink',
								type: 'to',
								params: {
									caseType: CASE_TYPE.NORMAL,
									checkActionCode: hResultDict.checkActionCode,
									// 添加检查事项名称和code 解决立案页面无法显示问题 fsx 2023-12-8 开始
									superviseItemName: hResultDict.superviseItemName,
									jgsxDealUuid: hResultDict.jgsxDealUuid,
									// 添加检查事项名称和code 解决立案页面无法显示问题 fsx 2023-12-8 结束
									checkUuid: this.taskInfo.checkUuid,
									caseSource: CASE_SOURCE.marketCheck, // 市场查获
									from: 'check', // 表示从市管过去的
									undertaker: this.taskInfo.undertaker,
									undertakerUuid: this.taskInfo.undertakerUuid,
									applyCode: this.applyCode,
									isReportHotline: this.isReportHotline,
									isSpecialAction: hResultDict.isSpecialAction == '1',
									actionUuid: hResultDict.actionUuid || '',
									actionName: hResultDict.actionName || '',
								},
							});
						}
						break;
					default:
						break;
				}
			},
			// 提交检查任务
			handlerSubmit() {
				this.$modal.confirm('请确认申请人/零售户姓名(名称)、身份证件信息是否正确，此数据一经提交将推送国家互联网+监管系统！', () => {
					console.log('待提交的数据', this.taskInfo);
					// 判断当前检查是否异常
					let isMakeCase = false;
					let isHaveHandleResult = false;
					if (this.taskInfo.singleCheckRecords && this.taskInfo.singleCheckRecords.length > 0) {
						for (let cr of this.taskInfo.singleCheckRecords) {
							console.log(cr.itemName, cr.checkData, cr.checkHandleResult);
							// 选择一般案件或者简易案件做立案等处理方式
							// 有检查异常
							if (cr.checkData === 'true' || cr.checkData === true) {
								isMakeCase = true;
								// 选择处理方式
								if (cr.checkHandleResult) {
									isHaveHandleResult = true;
								}
								// break;
							}
						}
					}
					if (!isMakeCase && !isHaveHandleResult) {
						this.$modal.confirm('未发现检查异常，是否提交？', () => {
							this.submitTask();
						});
					} else {
						// 选择处理方式
						if (isHaveHandleResult) {
							// 选择处理方式
							this.checkResultTypeDict.map((c) => {
								c.uid = c.value;
								c.name = c.label;
							});
							this.checkedResultType = this.parseTaskResult();
							this.checkResultTypeOpen = true;
						} else {
							// 未选择处理方式
							this.$modal.confirm('已发现检查异常，是否提交？', () => {
								this.taskInfo.dealType = M_CHECK_HANDLE_RESULT.NO_PROBLEM; // "10210011";
								this.submitTask();
							});
						}
					}
				});
			},
			// 选择检查结果回调
			handlerSelectResultType(items) {
				if (items.length == 0) {
					this.$u.toast('请选择处理结果');
					return;
				}
				console.log(items);
				this.checkResultTypeOpen = false;
				this.$modal.confirm('确定提交吗？提交后无法修改并推送至国家互联网+监管系统！', () => {
					// 检查结果处理
					this.taskInfo.checkHandleResults = items;
					this.submitTask();
				});
			},
			// 从检查结果中获取处理方式
			parseTaskResult() {
				let resultTypes = [];
				this.taskInfo.singleCheckRecords.forEach((cr) => {
					// 处理案件类型
					cr.checkHandleResult && resultTypes.push(cr.checkHandleResult);
				});
				return resultTypes;
			},
			// 提交检查任务
			submitTask() {
				this.taskInfo.checkTime = dateUtils.dateFormat('yyyy-MM-dd HH:mm:ss', new Date());
				this.taskInfo.checkDate = dateUtils.dateFormat('yyyy-MM-dd', new Date());
				let submitTask = this.$u.deepClone(this.taskInfo);

				if (submitTask.singleCheckRecords && submitTask.singleCheckRecords.length > 0) {
					submitTask.checkRecords = submitTask.singleCheckRecords.filter((itm) => {
						itm.isUnusual = itm.checkData ? 1 : 0;
						if (itm.checkData === 'true' || itm.checkData === true) {
							itm.checkData = 1;
						}
						if (itm.checkData === 'false' || itm.checkData === false) {
							itm.checkData = 0;
						}
						return itm.checkData;
					});
				} else {
					submitTask.checkRecords = [];
				}

				submitTask.status = M_DAY_CHECK_STATUS.FINISH;
				submitTask.statusName = '已完成';
				delete submitTask.singleCheckRecords;
				console.log(submitTask);
				this.$u.loading('提交中...');
				checkService
					.submitCheckRecord(submitTask)
					.then(async (dr) => {
						if (dr.success) {
							// 刷新当前页面
							this.taskInfo.status = M_DAY_CHECK_STATUS.FINISH;
							this.checkInfo.status = M_DAY_CHECK_STATUS.FINISH;
							this.checkTime = dateUtils.dateFormat('yyyy-MM-dd HH:mm:ss', new Date());
							// 设置钉钉头部右侧操作按钮
							this.queryCheckResultDetail(() => this.setRightBtnsCheck());
							// 提交成功后删除缓存
							uni.removeStorageSync(this.localStoreTaskKey);
							// 判断提交的检查项当中 地理标识中的 幼儿园周边/中小学周边 是否勾选 操作重点监管户标签
						  await	this.sendPrimaryTagData(submitTask);
							this.$u.hideLoading();
							this.$u.toast('提交成功！');
						} else {
              				this.$u.hideLoading();
							this.$u.toast(dr.msg);
						}
					})
					.catch((err) => {
						this.$u.hideLoading();
						this.$u.toast(err);
					});
			},
			// 回写贴重点监管对象标识
			async sendPrimaryTagData(data) {
        let yeyGisData ,zxeGisData;
        if (this.taskInfo.singleCheckRecords){
           yeyGisData = this.taskInfo.singleCheckRecords.filter(task => task.itemUuid === '340202030101')[0];
           zxeGisData =  this.taskInfo.singleCheckRecords.filter(task => task.itemUuid === '340202030201')[0];
        }
				let  tagFlag = false;
				let  zxuFlag = false;
				let  yeyFlag = false;
				if (yeyGisData && yeyGisData.gisDataList && yeyGisData.gisDataList.length > 0 ){
					yeyFlag = true;
					tagFlag = true;
				}
				if (zxeGisData && zxeGisData.gisDataList && zxeGisData.gisDataList.length > 0 ){
					zxuFlag = true;
					tagFlag = true;
				}
				// 组装数据
				let paramArray = [];
				if (tagFlag){
					let zdParam = {
						tagField: 'IS_PRIMARY_SUPRISE_OBJECT',
						hostCode: 'R_LICENSE_INFO',
						isDel: tagFlag ? '0' : '1',
						val: '1',
						valName: '是',
					};
					paramArray.push(zdParam);
				}
				if (yeyFlag) {
					let yeyParam = {
						tagField: 'PRIMARY_SUPRISE_OBJECT_DETAIL',
						hostCode: 'R_LICENSE_INFO',
						isDel: yeyFlag ? '0' : '1',
						val: '05',
						valName: '幼儿园周边'
					};
					paramArray.push(yeyParam);
				}
				if (zxuFlag) {
					let zxuParam = {
						tagField: 'PRIMARY_SUPRISE_OBJECT_DETAIL',
						hostCode: 'R_LICENSE_INFO',
						isDel: zxuFlag ? '0' : '1',
						val: '04',
						valName: '中小学周边'
					};
					paramArray.push(zxuParam);
				}
				if (paramArray.length == 0){
					return;
				}

				let param = {
					retailerUuid:data.retailerUuid,
					dataList:paramArray,
				};

				console.log(param);
        await rlicService.saveOrDelTagHostDataBatch(param).then((res) => {
				if(res.success){
					console.log("更新重点监管对象成功");
				}else{
					console.log(res.msg);
				}
				}).catch((err) => {
					console.log(err);
				});
			},
      // 设置钉钉右侧操作按钮
			setRightBtnsCheck() {
				// #ifdef H5-DINGDING
				if (this.checkDealTypes.length > 0) {
					this.$deviceApi.setRight('更多', () => {
						this.isOpen = true;
						this.setRightBtnsCheck();
					}, true, true);
				}
				// #endif
			},
			fabtrigger(btn) {
				if (btn.index == 0) {
					this.isOpen = true;
				}
			},
			updateEvent(param) {
				if (param.surGis && this.menuItem.type == 'out') {
					// 表示需要刷新指定
					this.$refs.refCom.updateGisData(param.surGis);
				}
			},
		},
	};
</script>
<style lang="scss" scoped>
	.page {
		padding: 0;
	}

	.flat-circle {
		position: fixed;
		z-index: 999;
		right: 30rpx;
		bottom: 200rpx;
		border-radius: 30px;
		color: white;
		width: 100px;
		height: 30px;
		background-color: #666666;
		font-size: 20rpx;
		text-align: center;
		padding: 20rpx;

		&-item {
			margin-top: -6px;
			font-size: 13px;
			align-items: center;

			&-title {
				position: relative;
				left: 3px;
				top: -6px;
			}
		}
	}

	.content {
		background-color: #fff;

		.c-title {
			opacity: 0.8;
			color: #000;
			font-weight: 600;
			font-size: 16px;
			//text-align: center;
			width: 100%;
			z-index: 99;
			padding: 20px;
		}

		.opt-img {
			z-index: 99;
			width: 100%;
			height: 140rpx;
		}

		.grid-text {
			font-size: 28rpx;
			margin-top: 10rpx;
			color: #333;
		}
	}

	.u-checkbox-group {
		width: 100%;
	}

	.credit-container {
		height: 88rpx;
		border-bottom: 1px solid #e6e6e6;

		.info {
			display: flex;
			align-items: center;
			line-height: 100%;
			color: #999999;
			font-size: 12px;

			.info-item {
				background-color: #eff3f9;
				border-radius: 5px;
				margin-right: 5px;
				padding: 5px 8px;
			}
		}
	}

	.title {
		text-overflow: ellipsis;
		word-break: break-all;
		overflow: hidden;
		white-space: nowrap;
	}

	/deep/ .u-dot {
		background: #bbbdbf;
	}

	/deep/.u-time-axis {
		order-left: 1px solid #bbbdbf;
	}

	/deep/.submit-btns {
		position: sticky;
	}
</style>
